//index.js
//获取应用实例
var app = getApp()
Page({
  data: {
    userInfo: {},
    poster: 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000',
    name: '演员',
    author: '薛之谦',
    src: 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&fromtag=46',
    per: 0,
    btnPlaySrc: '../../static/btn_play.png',
    audio: {
      status: 0 // 0-pause 1-play
    }
  },
  prosUpdate: function(data) {
    this.setData({ per: data.detail.currentTime / data.detail.duration * 100 }) 
  },
  setPros: function (data) {
  },
  audioPlay: function(e) {
    this.audioCtx.play()
  },
  audioPause: function () {
    this.audioCtx.pause()
  },
  audioSet: function () {
    this.audioCtx.seek(14)
  },
  audioRestart: function () {
    this.audioCtx.seek(0)
  },
  onReady: function(e) {
    this.audioCtx = wx.createAudioContext('myAudio')
  },
  onLoad: function () {
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:userInfo
      })
    })
  }
})
